#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
    int num;
    cin >> num;
    size_t x = 0, y = 1, z;
    while (true) {
        if (num >= x && num <= y) {
            cout << ((num - x) > (y - num) ? (y - num) : (num - x)) << endl;
            break;
        }
        z = x + y;
        x = y;
        y = z;
    }

    return 0;
}